/**
  我的实践计划
 */
<template>
    
    <div style="padding:0 20px;">
      
      <el-card shadow="never" v-loading="loading" body-style="padding: 24px;" class="card-margin">

          <el-row type="flex" class="row-bg" justify="space-between">
            <h2 style="font-weight:bold">{{$t('practicalPlan.myPlan')}}</h2>
            <el-button :disabled="!this.outsideAdvisorId" @click="cancelIntern" type="primary">{{$t('practicalPlan.downloadInternship')}}</el-button>
          </el-row>
          <hr style="border-top: 2px solid #eee;">

        <h2>{{$t('practicalPlan.information')}}</h2>
        <table  class="table-style-baseinfo">
          <tr>
              <td class="text-right-background-color">{{$t('practicalPlan.name')}}:</td>
              <td class="text-left-background-none">{{dataForm.name}}</td>
              <td class="text-right-background-color">{{$t('practicalPlan.gender')}}:</td>
              <td class="text-left-background-none">{{dataForm.sex==='1'?'男':(dataForm.sex==='2'?'女':'')}}</td>
            
          </tr>
          <tr>
              <td class="text-right-background-color">{{$t('practicalPlan.age')}}:</td>
              <td class="text-left-background-none">{{dataForm.age}}</td>
              <td class="text-right-background-color">{{$t('practicalPlan.affiliated')}}:</td>
              <td class="text-left-background-none">{{dataForm.department}}</td>
          </tr>
          <tr>
            <td class="text-right-background-color">{{$t('practicalPlan.posiDuty')}}:</td>
            <td class="text-left-background-none"  >{{dataForm.proTitle}}</td>
            <td class="text-right-background-color">{{$t('practicalPlan.contact')}}:</td>
            <td class="text-left-background-none"  >
              {{dataForm.contactPhone}}
            </td>
          </tr>
          <tr>
              <td class="text-right-background-color">{{$t('practicalPlan.contactMail')}}:</td>
              <td class="text-left-background-none" colspan="3" style="max-width: 300px; word-wrap: break-word; overflow: auto;">{{dataForm.contactEmail}}</td>
              
          </tr>
         
          <tr>
              <td class="text-right-background-color">{{$t('practicalPlan.introduction')}}:</td>
              <td class="text-left-background-none" colspan="3" style="max-width: 300px; word-wrap: break-word; overflow: auto;">{{dataForm.introduction}}</td>   
          </tr>
          
       
        </table>
        <h2>{{$t('practicalPlan.experience')}}</h2>
        <table class="table-style-baseinfo">
          <tr>
              <td class="text-right-background-color">{{$t('practicalPlan.workDate')}}:</td>
              <td class="text-left-background-none">{{dataFormList.workStart?dataFormList.workStart+'/'+dataFormList.workEnd:''}}</td>
              <td class="text-right-background-color">{{$t('practicalPlan.submission')}}:</td>
              <td class="text-left-background-none">{{dataFormList.submitFrequency}}</td>
          </tr>
         
          <tr>
            <td class="text-right-background-color">{{$t('practicalPlan.program')}}:</td>
            <td class="text-left-background-none" colspan="3" style="max-width: 300px; word-wrap: break-word; overflow: auto;">{{dataFormList.practiceContent}}</td>
              
          </tr>
        </table>
      </el-card>
     
    </div>
    
</template>
<script>
import HistoryTable from 'common/src/views/graduateStudent/component/HistoryTable';
import { queryDic } from "common/src/api/dictionary";
import UTILS from "common/src/utils/utils";
import graduateStudent from 'common/src/api/graduateStudent/graduateStudent';
export default {
  data() {
    return{
      dataFormList: {}, //接收路由跳转的数据
      dataForm: {
        
      }, //表格数据
      internship: {
        opinion: ''
      },
      outsideAdvisorId: '',
      curCheckStandard: '',
      curPracticeId: '',
      options: {
        facultys: [],
        degreeType: [],
        title: [],
        sex: [],
      },
      internshipRule: {
        opinion: [
            {
                required: true,
                message: this.$t('myExamine.reviewComments'),
                trigger: "blur"
            }
        ]
      },
      tableData: []
    }
  },
  filters: {
    collegeAcademyList(val, array) {
      let str = "";
      for (let item of array) {
        if (val === item.value) {
          str = item.label;
        }
      }
      return str;
    }
  },
  watch: {
    showFlag: {
      handler: function(newV, oldV) {
        if (newV) {
          // this.dataForm = this.$route.query.data;
          // this.tableData = this.$route.query.list;
        }
      }
    }
  },
  mounted() {
    this.getOptions();
    this.getQueryPractice();
  },
  created() {
    
  },
  methods: {
    // 下载
    download (path) {
      downloadfile(path);
    },
    getQueryPractice() {

      graduateStudent.getQueryPracticePlan().then(res => {
        // console.log(res, 'sdfds');
        // if (res.data.outsideAdvisorId) {
        this.outsideAdvisorId = res.data.outsideAdvisorId;
        // }
        this.dataFormList = res.data;
        
      }).then(() => {
        if (this.outsideAdvisorId) {
          graduateStudent.getQueryPract(this.outsideAdvisorId).then(resd => {
            // console.log(resd, 'resd110');
            this.dataForm = resd.data;
          });
        }
      });
    },
    cancelIntern() {
      if (this.outsideAdvisorId) {
        graduateStudent.exportdownPlan(this.dataFormList.id);
        // .then(resd => {
        //   this.$message({
        //       type: "success",
        //       message: this.$t('identificationToDoList.SuccessfulOperation')
        //   });
        // });
      }
    },
    getOptions() {
      // 筛选条件字典查询
      let data = {
        lang: this.$store.getters.language || "cn",
        type: "allChild",
        keys: ["X_YX", 'G_XBIE', "JDJB",]
      };
      queryDic(data).then(res => {
        UTILS.fillSelect(
          {
            facultys: "X_YX",
            degreeType: "JDJB",
            sex:"G_XBIE"
          },
          res.data,
          this.options
        );
        // console.log(this.options);
        
      });
    },
    // 驳回
    reject() {
      if (this.internship.opinion.indexOf("$") < 0) {
        if (this.internship.opinion) {
          let practiceIds = [];
          practiceIds.push({
            no: this.$route.query.data.actNo,
            content: this.internship.opinion
          });
          graduateStudent.internshipRefuse(practiceIds).then((data) => {
            this.$message({
                type: "success",
                message: this.$t('identificationToDoList.SuccessfulOperation')
            });
            this.goBack();
          });
        } else {
          this.$message({
              type: "error",
              message: this.$t('myExamine.reviewComments')
          });
        }
      } else {
        this.$message({
            type: "error",
            message: this.$t('identificationToDoList.cannotContain')
        });
      }
    },
    // 通过
    pass() {
      // 
      if (this.internship.opinion.indexOf("$") < 0) {
        let practiceIds = [];
        practiceIds.push({
          no: this.$route.query.data.actNo,
          content: this.internship.opinion
        });
        graduateStudent.internshipAgree(practiceIds).then((data) => {
          this.$message({
              type: "success",
              message: this.$t('identificationToDoList.SuccessfulOperation')
          });
          this.goBack();
        });
      } else {
        this.$message({
            type: "error",
            message: this.$t('identificationToDoList.cannotContain')
        });
      }
    },
    goBack() {
      this.$store.commit("delete_tabs", this.$route.path);
      this.$router.go(-1);
    },
    // 获取表格数据
    assignment() {
    
    },
  },
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.inner-breadcrumb {
    .breadcrumb {
        span {
            font-weight: normal;
            color: #aaa;
        }
        a {
            font-weight: normal;
            color: #aaa;
        }
        a:hover {
            color: #409eff;
        }
        .last {
            font-weight: bold !important;
            cursor: default !important;
        }
        .disable {
            cursor: default !important;
        }
    }
}
.condition-title-p {
    font-weight: 400;
    font-style: normal;
    color: #2b3b4e;
    font-size: 18px;
    margin-bottom: 15px;
}
.base-info-title {
    font-weight: 400;
    font-style: normal;
    font-size: 16px;
    color: #2b3b4e;
}
.table-style-baseinfo {
    background-color: rgba(210, 212, 214, 1);
    box-sizing: border-box;
    border-width: 0.5px;
    border-style: solid;
    border-color: rgba(210, 212, 214, 1);
    border-radius: 0px;
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    box-shadow: none;
    width: 100%;
    font-weight: 401;
    font-style: normal;
    font-size: 14px;
    color: #8896a7;
    margin-bottom: 20px;
}

.table-style-baseinfo td {
    width: 25%;
    background-color: rgba(255, 255, 255, 1);
    border: none;
    border-radius: 0px;
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    box-shadow: none;
    font-weight: 401;
    font-style: normal;
    font-size: 14px;
    color: #2b3b4e;
    height: 32px;
    padding: 0 10px;
}

.table-style-baseinfo .text-right-background-color {
    background-color: #fdfeff4d;
    text-align: right;
}

.text-left-background-none {
    text-align: left;
}
</style>